package interview.huawei.tjt.training.huaweijishitiku;

import java.util.Arrays;
import java.util.Scanner;

// 输入n个整数，输出其中最小的k个
public class HJ58 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while ( sc.hasNextInt() ) {

            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] arr = new int[n];
            for ( int i = 0; i < n; i ++ ) {
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append(arr[0]);

            if ( k == 1 ) {
                System.out.println(stringBuffer);
            } else {
                for ( int i = 2; i <= k; i ++ ) {
                    stringBuffer.append(" ").append(arr[i - 1]);
                }
                System.out.println(stringBuffer);
            }


        }

    }

}
